<?php

class Painel_Form_Stpagina extends Zend_Form
{

    public function init()
    {
        Zend_Loader::loadClass('dominio','library');
        
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        
        $this->setName('form_edt');
        
        $el = new Zend_Form_Element_Hidden('PGS_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))
            ->addFilter('Int');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PGS_NOMMEN');
        $el->setLabel('Nome do Menu');
        $el->setRequired(true);
        $el->setAttrib('class', 'form-control');
        $el->setAttrib('required', '');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Checkbox('PGS_STAMEN',array('checked'=>'checked'));
        $el->setLabel('Mostrar no Menu');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PGS_PAGREF');
        $el->setLabel('Referência Click Menu / Página - Site inteiro com apenas uma página');
        $el->setAttrib('class', 'form-control');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PGS_NOM');
        $el->setLabel('Nome da Página');
        $el->setRequired(true);
        $el->setAttrib('class', 'form-control'); 
        $el->setAttrib('required', '');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PGS_PAGPRI');
        $el->setLabel('Página Principal - Informar caso seja uma subpágina');
        $el->setAttrib('class', 'form-control');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Textarea('PGS_TXT');
        $el->setLabel('Texto');
        //$el->setRequired(true);
        $el->setAttrib('class', 'form-control');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PGS_LNK');
        $el->setLabel('Link');
        $el->setAttrib('class', 'form-control');
        //$el->setRequired(true);
        //$el->setAttrib('required', '');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PGS_ORD');
        $el->setLabel('Ordem');
        $el->setRequired(true);
        $el->setAttrib('class', 'form-control');
        $el->setAttrib('required', '');
        $this->addElement($el);
        
        
        $paginasEstaticas = dominio::paginasEstaticas();
        $el = new Zend_Form_Element_Select('PGS_PAGEST',array('onchange' => ''));
        $el->setLabel('Página Estática - Define uma pagina criada internamente pelo sistema')
        ->addMultiOptions($paginasEstaticas);
        $el->setAttrib('class', 'form-control');
        $this->addElement($el);
        
        
        /*
        $img = glob('public/upload/'.$controller.'/'.$front->getRequest()->getParam('id').'.*');
        if(isset($img[0]))
        foreach($img as $src) {
            $el = new Zend_Form_Element('img',array( 'helper'=>'formNote', 'value'=>'<img src="'.$front->getBaseUrl().'/'.$src.'" />' ));
            $this->addElement($el);
        }
        $el = new Zend_Form_Element_File('PGS_FILE');
        $el->setLabel('Imagem - 390x150')->addValidator('Extension', false, array('jpg', 'png', 'gif'));
        $this->addElement($el);
        */
        
        $el = new Zend_Form_Element_Checkbox('PGS_STA',array('checked'=>'checked'));
        $el->setLabel('Ativo');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element('br',array( 'helper'=>'formNote', 'value'=>'&nbsp;' ));
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Button('Salvar',array('disableLoadDefaultDecorators' =>true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<button type="submit" class="btn btn-lg btn-success"><span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> Salvar</button>');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn btn-lg btn-danger"><span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span> Cancelar</a>');
        $this->addElement($btn);
     
    }


}

